/**
 * 
 */
package com.xcesys.extras.dataobject.schedule;

import java.io.Serializable;
import java.util.Date;

import com.xcesys.extras.dataobject.NameValuePair;

/**
 * Data object class that hold {@link Trigger} and {@link JobDetail}
 * information.
 * 
 * @author LiangShenFan
 */
public class TriggerDataObject implements Serializable {
	public enum TriggerState {
		NONE, NORMAL, PAUSED, COMPLETE, ERROR, BLOCKED
	}

	public static final String DEFAULT_GROUP = "DEFAULT";

	public static final String DEFAULT_MANUAL_TRIGGERS = "MANUAL_TRIGGER";

	private static final long serialVersionUID = -3364336249719123452L;;

	/**
	 * <p>
	 * Indicates that the <code>Trigger</code> is in the "blocked" state.
	 * </p>
	 * 
	 * <p>
	 * A <code>Trigger</code> arrives at the blocked state when the job that it
	 * is associated with is a <code>StatefulJob</code> and it is currently
	 * executing.
	 * </p>
	 * 
	 * @see StatefulJob
	 */
	public static final int STATE_BLOCKED = TriggerState.BLOCKED.ordinal();

	/**
	 * <p>
	 * Indicates that the <code>Trigger</code> is in the "complete" state.
	 * </p>
	 * 
	 * <p>
	 * "Complete" indicates that the trigger has not remaining fire-times in its
	 * schedule.
	 * </p>
	 */
	public static final int STATE_COMPLETE = TriggerState.COMPLETE.ordinal();
	/**
	 * <p>
	 * Indicates that the <code>Trigger</code> is in the "error" state.
	 * </p>
	 * 
	 * <p>
	 * A <code>Trigger</code> arrives at the error state when the scheduler
	 * attempts to fire it, but cannot due to an error creating and executing
	 * its related job. Often this is due to the <code>Job</code>'s class not
	 * existing in the class path.
	 * </p>
	 * 
	 * <p>
	 * When the trigger is in the error state, the scheduler will make no
	 * attempts to fire it.
	 * </p>
	 */
	public static final int STATE_ERROR = TriggerState.ERROR.ordinal();

	/**
	 * <p>
	 * Indicates that the <code>Trigger</code> does not exist.
	 * </p>
	 */
	public static final int STATE_NONE = TriggerState.NONE.ordinal();

	/**
	 * <p>
	 * Indicates that the <code>Trigger</code> is in the "normal" state.
	 * </p>
	 */
	public static final int STATE_NORMAL = TriggerState.NORMAL.ordinal();

	/**
	 * <p>
	 * Indicates that the <code>Trigger</code> is in the "paused" state.
	 * </p>
	 */
	public static final int STATE_PAUSED = TriggerState.PAUSED.ordinal();

	/**
	 * Type constants indicates this is a cron trigger.
	 */
	public static final int TRIGGER_TYPE_CRON = 2;

	/**
	 * Type constants indicates this is a simple trigger.
	 */
	public static final int TRIGGER_TYPE_SIMPLE = 1;

	/**
	 * Cron expression while trigger type is {@link #TRIGGER_TYPE_CRON}.
	 */
	private String cronExpression;

	/**
	 * Trigger description.
	 */
	private String description;

	/**
	 * End time while trigger type is {@link #TRIGGER_TYPE_SIMPLE}.
	 */
	private Date endTime;

	/**
	 * Trigger group.
	 */
	private String group;

	/**
	 * Job class full qualified name.
	 */
	private String jobClass;

	/**
	 * Job description.
	 */
	private String jobDescription;

	/**
	 * Job group.
	 */
	private String jobGroup;

	/**
	 * Job name
	 */
	private String jobName;

	private NameValuePair[] jobParams;
	/**
	 * May fire again.
	 */
	private Boolean mayFireAgain;

	/**
	 * Trigger name.
	 */
	private String name;

	/**
	 * Next fire time.
	 */
	private Date nextFireTime;

	/**
	 * Previous run time elapse.
	 */
	private Long prevElapse;

	/**
	 * Previous fire time.
	 */
	private Date previousFireTime;

	/**
	 * Repeat count while trigger type is {@link #TRIGGER_TYPE_SIMPLE}.
	 */
	private Integer repeatCount;

	/**
	 * Repeat interval while trigger type is {@link #TRIGGER_TYPE_SIMPLE}.
	 */
	private Long repeatInterval;

	/**
	 * Start time while trigger type is {@link #TRIGGER_TYPE_SIMPLE}.
	 */
	private Date startTime;

	/**
	 * Trigger status.
	 */
	private TriggerState triggerStatus;

	/**
	 * Trigger status name.
	 */
	private String triggerStatusName = "";

	/**
	 * Trigger type.
	 */
	private int triggerType = TRIGGER_TYPE_SIMPLE;

	public String getCronExpression() {
		return cronExpression;
	}

	public String getDescription() {
		return description;
	}

	public Date getEndTime() {
		return endTime;
	}

	public String getGroup() {
		return group;
	}

	public String getJobClass() {
		return jobClass;
	}

	public String getJobDescription() {
		return jobDescription;
	}

	public String getJobGroup() {
		return jobGroup;
	}

	public String getJobName() {
		return jobName;
	}

	public NameValuePair[] getJobParams() {
		return jobParams;
	}

	public Boolean getMayFireAgain() {
		return mayFireAgain;
	}

	public String getName() {
		return name;
	}

	public Date getNextFireTime() {
		return nextFireTime;
	}

	public Long getPrevElapse() {
		return prevElapse;
	}

	public Date getPreviousFireTime() {
		return previousFireTime;
	}

	public Integer getRepeatCount() {
		return repeatCount;
	}

	public Long getRepeatInterval() {
		return repeatInterval;
	}

	public Date getStartTime() {
		return startTime;
	}

	public TriggerState getTriggerStatus() {
		return triggerStatus;
	}

	public String getTriggerStatusName() {
		return triggerStatusName;
	}

	public int getTriggerType() {
		return triggerType;
	}

	public Boolean isMayFireAgain() {
		return mayFireAgain;
	}

	public void setCronExpression(String cronExpression) {
		this.cronExpression = cronExpression;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public void setGroup(String group) {
		this.group = group;
	}

	public void setJobClass(String jobClass) {
		this.jobClass = jobClass;
	}

	public void setJobDescription(String jobDescription) {
		this.jobDescription = jobDescription;
	}

	public void setJobGroup(String jobGroup) {
		this.jobGroup = jobGroup;
	}

	public void setJobName(String jobName) {
		this.jobName = jobName;
	}

	public void setJobParams(NameValuePair[] jobParams) {
		this.jobParams = jobParams;
	}

	public void setMayFireAgain(Boolean mayFireAgain) {
		this.mayFireAgain = mayFireAgain;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setNextFireTime(Date nextFireTime) {
		this.nextFireTime = nextFireTime;
	}

	public void setPrevElapse(Long prevEllapse) {
		this.prevElapse = prevEllapse;
	}

	public void setPreviousFireTime(Date previousFireTime) {
		this.previousFireTime = previousFireTime;
	}

	public void setRepeatCount(Integer repeatCount) {
		this.repeatCount = repeatCount;
	}

	public void setRepeatInterval(Long repeatInterval) {
		this.repeatInterval = repeatInterval;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public void setTriggerStatus(TriggerState triggerStatus) {
		this.triggerStatus = triggerStatus;
	}

	public void setTriggerStatusName(String triggerStatusName) {
		this.triggerStatusName = triggerStatusName;
	}

	public void setTriggerType(int trigerType) {
		this.triggerType = trigerType;
	}

}
